package easychat;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Receiver {
    public static void main(String[] args) throws IOException {
        //1.创建客户端对象
        ServerSocket ss = new ServerSocket(1002);
        //2.监听,等待连接
        Socket socket = ss.accept();
        //3.接受数据并解析打印
        //3.1使用转换流进行读取
        InputStreamReader isr = new InputStreamReader(socket.getInputStream());
        int b;
        System.out.print("ta:");
        while((b = isr.read()) != -1){
            System.out.print((char)b);
        }
        System.out.println();

        socket.close();
        ss.close();

    }
}
